/*
 @description：token
*/
function checkToken() {
    return async function (ctx, next) {
        const {
            token
        } = ctx.request.header;
        // console.log(token);
        if (token) {
            const result = ctx.app.jwt.verify(token, ctx.app.config.jwt.sercet);
            if (result.end_time >= Date.now() / 1000) {
                await next();
            } else {
                ctx.body = {
                    code: 4004,
                    msg: 'token失效'
                }
            }
        } else {
            ctx.body = {
                code: 4001,
                msg: 'token不存在'
            }
        }
    }
}
module.exports = checkToken;